package com.lxl.demo;

import java.util.Arrays;

public class Demo4 {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int m = nums1.length,n = nums2.length;
        int[] mn = new int[m+n];
        for(int i=0;i<m;i++){
            mn[i] = nums1[i];
        }
        for(int i=0;i<n;i++){
            mn[m+i] = nums2[i];
        }
        Arrays.sort(mn);
        if((m+n) % 2 == 1){
            int temp = mn[(m+n+1)/2 -1];
            return (double)temp;
        }else{
            int temp2 = (m+n)/2;
            double res = ((double)mn[temp2-1] + (double)mn[temp2]) / 2;
            return res;
        }
    }

    public static void main(String[] args) {
        Demo4 demo4 = new Demo4();
        demo4.findMedianSortedArrays(new int[]{1,2}, new int[]{3,4});
    }
}
